﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Root.master" AutoEventWireup="true" CodeFile="dog.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="Server">
    <script src="../Scripts/toolbar.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        // <![CDATA[
        function OnGetRowValues(values) {
            lbl_NO.SetText('Загрузка нового файла к договору № ' + values);
        }
        // ]]>
    </script>
    <div class="pageLabel">
        <dx:ASPxLabel ID="ASPxLabel3" runat="server" Text="Список договоров" Font-Size="Medium" Theme="iOS">
        </dx:ASPxLabel>
    </div>
    <div style="float: left; margin-left: 10px;">

        <dx:ASPxMenu ID="mMenu" runat="server" EnableViewState="False" EncodeHtml="False" SeparatorWidth="2px" BackColor="Transparent"
            SeparatorHeight="15px" ItemSpacing="1px">
            <SeparatorBackgroundImage ImageUrl="~\Images\shared\ToolBars\Office2003\SeparatorBackground.png" />
            <ClientSideEvents ItemClick="function(s, e) { MenuItemClick(e, grd_Dog); }" />
            <Items>
                <dx:MenuItem Name="btn_Insert" Text="" ToolTip="Добавить запись" GroupName="grp_edit" BeginGroup="True">
                    <Image Url="~/Images/shared/edit_add.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem GroupName="grp_edit" Name="btn_edit" Text="" ToolTip="Редактировать запись">
                    <Image Url="~/Images/shared/edit.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem GroupName="grp_edit" Name="btn_Delete" Text="" ToolTip="Удалит запись">
                    <Image Url="~/Images/shared/editdelete.png">
                    </Image>
                </dx:MenuItem>
                <dx:MenuItem GroupName="grp_settings" Name="btn_column" Text="" ToolTip="Настройка колонок">
                    <Image Url="~/Images/shared/group.png">
                    </Image>
                </dx:MenuItem>
            </Items>
        </dx:ASPxMenu>
    </div>
    <dx:ASPxMenu ID="menu_exp" runat="server" OnItemClick="menu_exp_ItemClick">
        <Items>
            <dx:MenuItem Name="btn_Excel" Text="" ToolTip="Экспорт в Excel">
                <Image Url="~/Images/shared/EXCEL.png">
                </Image>
            </dx:MenuItem>
        </Items>
    </dx:ASPxMenu>
    <div style="float: left; margin-right: 10px; margin-left: 10px">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
        </asp:ScriptManager>
        <dx:ASPxGridView ID="grd_Dog" runat="server" DataSourceID="ds_dog" AutoGenerateColumns="False" KeyFieldName="CODE" ClientInstanceName="grd_Dog"
            OnRowInserting="grd_Dog_RowInserting" OnRowInserted="grd_Dog_RowInserted"
            OnCustomColumnDisplayText="grd_Dog_CustomColumnDisplayText"
            OnHtmlDataCellPrepared="grd_Dog_HtmlDataCellPrepared"
            OnHtmlRowPrepared="grd_Dog_HtmlRowPrepared"
            OnRowUpdated="grd_Dog_RowUpdated" OnRowUpdating="grd_Dog_RowUpdating" Width="979px"
            OnCellEditorInitialize="grd_Dog_CellEditorInitialize" OnRowDeleted="grd_Dog_RowDeleted">
            <ClientSideEvents FocusedRowChanged="function(s, e) {cbPanel.PerformCallback('select');
                                                                grd_Dog.GetRowValues(grd_Dog.GetFocusedRowIndex(), 'NOMDOG', OnGetRowValues);}" />
            <Columns>
                <dx:GridViewCommandColumn VisibleIndex="0">
                    <ClearFilterButton Visible="True">
                    </ClearFilterButton>
                </dx:GridViewCommandColumn>
                <dx:GridViewDataTextColumn FieldName="CODE" ReadOnly="True" VisibleIndex="1" Caption="Код" Width="20px">
                    <EditFormSettings Visible="False" />
                    <DataItemTemplate>
                        <a href="dogdop.aspx?id=<%# Eval("CODE") %>" style="color: #000000"><%# Eval("CODE") %></a>
                    </DataItemTemplate>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="Контрагент" FieldName="KONTRAGENT" VisibleIndex="2" Width="200px">
                    <PropertiesComboBox DataSourceID="ds_kontr" TextField="NAME" ValueField="CODE">
                    </PropertiesComboBox>
                    <FilterCellStyle BackColor="#CCCCCC" ForeColor="#CCCCCC">
                    </FilterCellStyle>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTextColumn FieldName="NOMDOG" VisibleIndex="3" Caption="Номер договора" Width="80px">
                    <FilterCellStyle BackColor="#CCCCCC" ForeColor="#CCCCCC">
                    </FilterCellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataDateColumn FieldName="DATADOG" VisibleIndex="4" Caption="Дата заключения договора" Width="100px">
                    <FilterCellStyle BackColor="#CCCCCC" ForeColor="#CCCCCC">
                    </FilterCellStyle>
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataDateColumn FieldName="DATAENDDOG" VisibleIndex="5" Caption="Дата завершения договора" Width="100px">
                    <FilterCellStyle BackColor="#CCCCCC" ForeColor="#CCCCCC">
                    </FilterCellStyle>
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataHyperLinkColumn FieldName="DATAPATH" VisibleIndex="6" Caption="Копия договора">
                    <PropertiesHyperLinkEdit TextField="FILENAME">
                        <Style ForeColor="Black">
                    </Style>
                    </PropertiesHyperLinkEdit>
                    <Settings AllowAutoFilter="False" AllowGroup="False" AllowHeaderFilter="False" />
                    <EditFormSettings Visible="False" />
                    <EditItemTemplate>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
                            <%--<Triggers>
                            <asp:PostBackTrigger ControlID="UploadBtn" />
                        </Triggers>--%>
                            <ContentTemplate>

                                <dx:ASPxUploadControl ID="ASPxUploadControl1" runat="server" ClientInstanceName="uploader"
                                    OnFileUploadComplete="ASPxUploadControl1_FileUploadComplete"
                                    ShowProgressPanel="True" ShowUploadButton="True" Width="100%">
                                    <ClientSideEvents FileUploadComplete="function(s, e) { uploader.SetVisible(false);
                                                                                       lblPath.SetText('файл загружен');}" />
                                </dx:ASPxUploadControl>

                                <dx:ASPxLabel ID="ASPxLabel1" ClientInstanceName="lblPath" runat="server" Text=""></dx:ASPxLabel>

                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </EditItemTemplate>
                </dx:GridViewDataHyperLinkColumn>
                <dx:GridViewDataTextColumn FieldName="FILENAME" ReadOnly="True" Visible="False" VisibleIndex="7" Caption="Файл договора">
                    <EditFormSettings Visible="False" Caption="Файл договора" />
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" ConfirmDelete="True" EnableCustomizationWindow="true" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
            <SettingsPager AlwaysShowPager="True"></SettingsPager>
            <Settings ShowFilterRow="True" ShowFooter="True" ShowGroupPanel="True" />
        </dx:ASPxGridView>
        <asp:EntityDataSource ID="ds_dog" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="DOG" AutoGenerateWhereClause="True">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_kontr" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="KONTRAGENT" Select="it.[CODE], it.[NAME]">
        </asp:EntityDataSource>
        <div style="float: left; margin-top: 10px">
            <div align="center" style="margin-bottom: 10px">
                <dx:ASPxLabel ID="lbl_dogNO" runat="server" Text="" ClientInstanceName="lbl_NO" Theme="iOS"></dx:ASPxLabel>
            </div>
            <dx:ASPxCallbackPanel ID="cbPanel" ClientInstanceName="cbPanel" runat="server" Width="200px" OnCallback="cbPanel_Callback" ShowLoadingPanelImage="False">
                <PanelCollection>
                    <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                        <dx:ASPxUploadControl ID="Upload" runat="server" OnFileUploadComplete="Upload_FileUploadComplete" ShowProgressPanel="True" ShowUploadButton="True" Width="344px" NullText="выберите новый файл договора" Theme="BlackGlass">
                            <ValidationSettings MaxFileSize="10000000">
                            </ValidationSettings>
                            <ClientSideEvents FileUploadComplete="function(s, e) {grd_Dog.Refresh();}" />
                        </dx:ASPxUploadControl>
                    </dx:PanelContent>
                </PanelCollection>
            </dx:ASPxCallbackPanel>
        </div>
    </div>
    <dx:ASPxGridViewExporter ID="grd_export" runat="server" GridViewID="grd_Dog"></dx:ASPxGridViewExporter>
</asp:Content>

